<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GOLD PLAN - 支付处理中</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 20px;
            color: #333;
        }
        
        .container {
            background: white;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            padding: 40px;
            max-width: 500px;
            width: 100%;
            text-align: center;
            position: relative;
            overflow: hidden;
        }
        
        .logo {
            font-size: 32px;
            font-weight: bold;
            color: #d4af37;
            margin-bottom: 20px;
            letter-spacing: 2px;
        }
        
        .status-area {
            margin: 25px 0;
            padding: 15px;
            border-radius: 10px;
            background-color: #f8f9fa;
        }
        
        .order-info {
            font-size: 18px;
            margin: 15px 0;
            color: #555;
        }
        
        .order-no {
            font-weight: bold;
            color: #d4af37;
            font-size: 22px;
            margin: 10px 0;
        }
        
        .loading-container {
            margin: 30px 0;
        }
        
        .loading-spinner {
            width: 60px;
            height: 60px;
            border: 5px solid #f3f3f3;
            border-top: 5px solid #37afd4;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .loading-text {
            font-size: 18px;
            color: #666;
        }
        
        .countdown {
            font-size: 16px;
            color: #888;
            margin-top: 10px;
        }
        
        .btn {
            background: linear-gradient(to right, #1baeae, #1baeae);
            color: rgb(250, 243, 243);
            border: none;
            padding: 12px 30px;
            font-size: 16px;
            border-radius: 50px;
            cursor: pointer;
            margin-top: 20px;
            font-weight: bold;
            transition: all 0.3s;
            box-shadow: 0 4px 15px rgba(27, 107, 160, 0.3);
        }
        
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(31, 89, 155, 0.4);
        }
        
        .footer {
            margin-top: 30px;
            font-size: 14px;
            color: #888;
        }
        
        .progress-bar {
            height: 6px;
            background-color: #e9ecef;
            border-radius: 3px;
            margin: 20px 0;
            overflow: hidden;
        }
        
        .progress {
            height: 100%;
            background: linear-gradient(to right, #1baeae, #1baeae);
            width: 0%;
            transition: width 0.5s ease;
        }
        
        @media (max-width: 480px) {
            .container {
                padding: 25px;
            }
            
            .logo {
                font-size: 28px;
            }
        }
    </style>
	<script type="text/javascript" charset="UTF-8" src="https://wx.gtimg.com/pay_h5/goldplan/js/jgoldplan-1.0.0.js"></script>
</head>
<body>
    <div class="container">
        
        <div class="status-area">
            <div class="order-info">支付状态：<span id="statusText">处理中...</span></div>
            <!-- <div class="order-info">订单号：</div>
            <div class="order-no" id="displayArea"></div> -->
        </div>
        
        <div class="loading-container">
            <div class="loading-spinner"></div>
            <div class="loading-text">正在处理您的支付，请稍候...</div>
            <div class="countdown" id="countdown">页面将在 <span id="seconds">3</span> 秒后自动跳转</div>
        </div>
        
        <div class="progress-bar">
            <div class="progress" id="progressBar"></div>
        </div>
        
        <button class="btn" onclick="manualJump()">立即跳转</button>
        
    </div>

    <script>
        // 获取URL参数
        const params = new URLSearchParams(location.search);
        const orderNo = params.get('orderNo');
        const status = params.get('status');
        
        // 显示订单号
        //document.getElementById('displayArea').innerText = orderNo || '未知订单';
        
        // 根据状态更新显示
        if (status === 'TRADE_SUCCESS') {
            document.getElementById('statusText').innerText = '支付成功';
            document.getElementById('statusText').style.color = '#28a745';
        } else {
            document.getElementById('statusText').innerText = '处理中...';
        }
        
        // 自动跳转倒计时
        let seconds = 3;
        const countdownElement = document.getElementById('seconds');
        const progressBar = document.getElementById('progressBar');
        
        function updateCountdown() {
            countdownElement.textContent = seconds;
            progressBar.style.width = `${(3 - seconds) * 20}%`;
            
            if (seconds <= 0) {
                jumpToOrderDetail();
            } else {
                seconds--;
                setTimeout(updateCountdown, 1000);
            }
        }
        
        // 跳转到订单详情页
        function jumpToOrderDetail() {
            const jumpUrl = 'https://njsfyshopfront.mynatapp.cc/#/order-detail?id=' + orderNo;
            
            // 如果是TRADE_SUCCESS状态，使用postMessage方式跳转
            if (status === 'TRADE_SUCCESS') {
                const mchData = {
                    action: 'jumpOut',
                    jumpOutUrl: jumpUrl
                };
                const postData = JSON.stringify(mchData);
                parent.postMessage(postData, 'https://payapp.weixin.qq.com');
            } else {
                // 其他状态直接跳转
                window.location.href = jumpUrl;
            }
        }
        
        // 手动跳转函数
        function manualJump() {
            seconds = 0;
            updateCountdown();
        }
        
        // 页面加载完成后开始倒计时
        window.onload = function() {
            // 通知父页面iframe已准备就绪
            const mchData = {
                action: 'onIframeReady',
                displayStyle: 'SHOW_CUSTOM_PAGE',
            };
            const postData = JSON.stringify(mchData);
            parent.postMessage(postData, 'https://payapp.weixin.qq.com');
            
            // 开始倒计时
            updateCountdown();
        };
    </script>
</body>
</html>